-
-
Notifications
You must be signed in to change notification settings - Fork 18
Add dashboard and widgets entities and functionality, and tests #1501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds dashboard and widget entities to support dashboard visualization functionality. The changes introduce database tables, entity models, repositories, use cases, controllers, and comprehensive end-to-end tests for both SaaS and non-SaaS environments.
Changes:
- Added DashboardEntity and DashboardWidgetEntity with supporting database migration
- Implemented full CRUD operations for dashboards and widgets with validation and authorization
- Added comprehensive e2e tests covering dashboard creation, updates, deletion, and widget management
- Integrated widgets with existing saved query functionality
Reviewed changes
Copilot reviewed 44 out of 44 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| backend/src/migrations/1768393822639-AddDashboardAndDashboardWigetEntities.ts | Database migration creating dashboard and dashboard_widget tables with foreign key relationships |
| backend/src/entities/visualizations/dashboard/dashboard.entity.ts | Dashboard entity definition with TypeORM decorators and relationships |
| backend/src/entities/visualizations/dashboard/dashboard-widget.entity.ts | Widget entity with JSON serialization/deserialization for widget_options |
| backend/src/entities/visualizations/dashboard/dashboards.controller.ts | REST API endpoints for dashboard CRUD operations with guards and Swagger documentation |
| backend/src/entities/visualizations/dashboard/dashboard-widgets.controller.ts | REST API endpoints for widget CRUD operations |
| backend/src/entities/visualizations/dashboard/use-cases/*.ts | Business logic for dashboard and widget operations including validation |
| backend/src/entities/visualizations/dashboard/repository/*.ts | Custom repository extensions for database queries |
| backend/test/ava-tests/saas-tests/dashboard-e2e.test.ts | Comprehensive e2e tests for SaaS environment |
| backend/test/ava-tests/non-saas-tests/non-saas-dashboard-e2e.test.ts | Comprehensive e2e tests for non-SaaS environment |
| backend/src/common/application/global-database-context.ts | Added dashboard and widget repositories to global context |
| backend/src/app.module.ts | Registered DashboardModule in application |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export class AddDashboardAndDashboardWigetEntities1768393822639 implements MigrationInterface { | ||
| name = 'AddDashboardAndDashboardWigetEntities1768393822639'; |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migration class name contains a typo: "Wiget" instead of "Widget". This should be "AddDashboardAndDashboardWidgetEntities1768393822639" to match the actual table name "dashboard_widget" being created.
| @Column({ type: 'uuid' }) | ||
| connection_id: string; |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type inconsistency: The DashboardEntity defines connection_id as uuid type (line 22), but ConnectionEntity.id is varchar(38). The migration correctly uses "character varying" but the entity decorator should be @column({ type: 'varchar', length: 38 }) to match the connection table's id type and the migration.
| .set('Accept', 'application/json'); | ||
|
|
||
| const createDashboardRO = JSON.parse(createDashboard.text); | ||
| console.log('🚀 ~ createDashboardRO:', createDashboardRO); |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug console.log statement should be removed before merging to production.
| position_y: widget.position_y, | ||
| width: widget.width, | ||
| height: widget.height, | ||
| widget_options: widget.widget_options as unknown as Record<string, unknown> | null, |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type casting with 'as unknown as' is used here, which bypasses TypeScript's type checking. The widget_options field is typed as string | null in the entity but is being parsed to an object in AfterLoad. Consider creating a proper type guard or validation function to ensure type safety instead of double casting.
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query( | ||
| `CREATE TABLE "dashboard" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying NOT NULL, "description" text, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), "connection_id" character varying NOT NULL, CONSTRAINT "PK_233ed28fa3a1f9fbe743f571f75" PRIMARY KEY ("id"))`, | ||
| ); | ||
| await queryRunner.query( | ||
| `CREATE TABLE "dashboard_widget" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "widget_type" character varying NOT NULL, "name" character varying, "description" text, "position_x" integer NOT NULL DEFAULT '0', "position_y" integer NOT NULL DEFAULT '0', "width" integer NOT NULL DEFAULT '4', "height" integer NOT NULL DEFAULT '3', "widget_options" json, "dashboard_id" uuid NOT NULL, "query_id" uuid, CONSTRAINT "PK_d776e45a42322c53e9167b00ead" PRIMARY KEY ("id"))`, | ||
| ); | ||
| await queryRunner.query( | ||
| `ALTER TABLE "dashboard" ADD CONSTRAINT "FK_61891f58faf0242381786d60334" FOREIGN KEY ("connection_id") REFERENCES "connection"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, | ||
| ); | ||
| await queryRunner.query( | ||
| `ALTER TABLE "dashboard_widget" ADD CONSTRAINT "FK_1d4cbbe2829d760116ce4472bd5" FOREIGN KEY ("dashboard_id") REFERENCES "dashboard"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, | ||
| ); | ||
| await queryRunner.query( | ||
| `ALTER TABLE "dashboard_widget" ADD CONSTRAINT "FK_2d30b309abbaf0e051fd89560b9" FOREIGN KEY ("query_id") REFERENCES "saved_db_query"("id") ON DELETE SET NULL ON UPDATE NO ACTION`, | ||
| ); |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding database indexes for frequently queried columns. The dashboard table should have an index on connection_id, and the dashboard_widget table should have indexes on dashboard_id and query_id to optimize query performance for the repository methods that filter on these columns.
No description provided.